﻿package smooth.core.object.flickrComponent.contextualMenu.flickrImageComponent {
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TouchEvent;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.AntiAliasType;
	import caurina.transitions.Tweener;	
	import smooth.core.object.flickrComponent.FlickrComponent;
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;
	import smooth.core.object.flickrUserComponent.FlickrUserComponent;
	
	public class GetPhotosByUserButton extends Sprite {
		
		[Embed(source="Arial.ttf", fontFamily="myFont")] 
		public var myFont:Class;
		
		public var initialPosX:int;
		public var initialPosY:int;
		public var t:TextField;
		private var text:String;
		private var user:FlickrUserComponent;
		
		public function GetPhotosByUserButton(text:String, user:FlickrUserComponent):void {
			this.text = text;
			this.user = user;
			// Init des visuels du composant			
			initGraphics();
			// Init des events du composant
			initEvents();	
			// Init des process du composant
			initProcess();
		}
		
		
		private function initGraphics():void {
			if (this.user != null) {
				var format:TextFormat= new TextFormat();
				format.font= "myFont";
				format.color= 0xFFFFFF;
				format.size = 30;
								
				this.t = new TextField();
				this.t.background = true;	
				this.t.backgroundColor = 0x000000;
				this.t.alpha = 0.8;
				this.t.embedFonts = true;
				this.t.selectable  = false;		 
				this.t.text = this.text;
				this.t.autoSize = TextFieldAutoSize.LEFT;
				this.t.x = 0;
				this.t.y = 0;
				this.t.setTextFormat(format);
				this.addChild(this.t);
			}
			
		}
		
		private function initProcess():void {
		}
		
		private function initEvents():void {
			this.addEventListener(TouchEvent.MOUSE_DOWN, this.doTouchDown);
			this.addEventListener(MouseEvent.MOUSE_DOWN, this.doMouseDown);
		}
		
		private function doMouseDown(e:MouseEvent):void {
			doProcessMouseDown();
		}
		
		private function doTouchDown(e:TouchEvent):void {
			doProcessMouseDown();
		}
  
		private function doProcessMouseDown():void {
			this.parent.parent.userPhotosSearchService(this.user);
		}
	}
	
}